package cn.lili.modules.store.serviceimpl;

import cn.lili.common.vo.PageVO;
import cn.lili.modules.store.entity.dos.StoreSft;
import cn.lili.modules.store.entity.vos.StoreSftSearchParams;
import cn.lili.modules.store.entity.vos.StoreSftVO;
import cn.lili.modules.store.mapper.StoreSftMapper;
import cn.lili.modules.store.service.StoreSftService;
import cn.lili.mybatis.util.PageUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StoreSftServiceImpl extends ServiceImpl<StoreSftMapper, StoreSft> implements StoreSftService {


    @Override
    public IPage<StoreSftVO> findByConditionPage(StoreSftSearchParams entity, PageVO page) {
        return this.baseMapper.getList(PageUtil.initPage(page), entity.queryWrapper());
    }

    @Override
    public StoreSftVO findById(String id) {
        return this.baseMapper.getDetail(id);
    }

    @Override
    public StoreSft getByStoreId(String storeId) {
        if (StringUtils.isEmpty(storeId)) {
            return null;
        }
        return this.getOne(new QueryWrapper<StoreSft>().eq("store_id", storeId));
    }

    @Override
    public List<StoreSft> findAudit() {
        return this.baseMapper.selectList(new QueryWrapper<StoreSft>().in("status", "CHECKING", "ACCOUNT_NEED_VERIFY", "AUDITING", "NEED_SIGN", "FROZEN"));
    }
}
